package huu.phong.youtube;

import java.util.LinkedList;

public class FixedLinkedList<T> extends LinkedList<T>{
	
	private static final long serialVersionUID = 2351821142748526598L;
	
	private int maxSize = 20;
	
	public FixedLinkedList(){
		
	}
	
	public FixedLinkedList(int maxSize){
		this.maxSize = maxSize;
	}
	
	public void addFirst(T e) {
		if (contains(e)){
			remove(e);
		}
		if (size() == maxSize){
			removeLast();
		}
		super.addFirst(e);
	};
}
